﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace DBService
{
	public partial class DlgVerifyUser : System.Windows.Forms.Form
	{
		public DlgVerifyUser()
		{
			this.InitializeComponent();
		}

		private void DlgVerifyUser_Load(object sender, EventArgs e)
		{
			foreach (DbUser dbUser in DbUser.GetAllUsers(BimServerDB.Default))
			{
				if (dbUser.Status == UserStatus.Unregistered)
				{
					this.dgvUser.Rows.Add(new object[]
					{
						dbUser.Name,
						true,
						dbUser.Id
					});
				}
			}
		}

		private void btnCancle_Click(object sender, EventArgs e)
		{
			base.Close();
		}

		private void btnOK_Click(object sender, EventArgs e)
		{
			if (this.dgvUser.Rows.Count > 0)
			{
				foreach (object obj in ((IEnumerable)this.dgvUser.Rows))
				{
					DataGridViewRow dataGridViewRow = (DataGridViewRow)obj;
					DbUser fromDB = DbUser.GetFromDB(Convert.ToInt32(dataGridViewRow.Cells["GUID"].Value), BimServerDB.Default);
					if (fromDB != null && (bool)dataGridViewRow.Cells["Verify"].Value)
					{
						fromDB.Verify();
					}
				}
				MessageBox.Show("用户已审核成功！");
			}
			base.Close();
		}
	}
}
